﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

namespace YABE.Models
{
    public class YabeDataManager
    {

        #region Field
		private static YabeDataManager _singleton = null;
		private static object _singletonLock = new object();
        private string _connectionString;
        //private YabeDataContext _yabeData;
		#endregion

		#region Constructor
        private YabeDataManager()
		{
            this._connectionString  = ConfigurationManager.ConnectionStrings["YabeConnectionString"].ConnectionString;
		}
		#endregion

        public static YabeDataManager Instance
		{
			get
			{
				if (_singleton == null)
				{
					lock (_singletonLock)
					{
                        _singleton = new YabeDataManager();
					}
				}
				return _singleton;
			}
		}

        public YabeDataContext  DataContext
        {
            get
            {
							YabeDataContext myContext = new YabeDataContext(this._connectionString);
							myContext.DeferredLoadingEnabled = false;
							return myContext;            
            }
        }


       
    }
}
